package com.schedule.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.schedule.mapper.GradeMapper;
import com.schedule.pojo.Grade;
import com.schedule.service.IGradeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author star
 * @since 2022-03-08
 */
@Service
public class GradeServiceImpl extends ServiceImpl<GradeMapper, Grade> implements IGradeService {

    @Autowired
    private GradeMapper gradeMapper;

    /**
     * 根据前端传来的选手ID，比赛ID，分数score三个参数来设置参数
     *  @param pid
     * @param cname
     * @param score
     * @return
     */
    @Override
    public boolean setScore(Integer pid, String cname, double score) {
        if (gradeMapper.setScore(pid, cname, score)!=0){
            return true;
        }
        return false;
    }

    /**
     * 根据前端传来的选手ID，比赛ID，分数score三个参数来更新参数
     *
     * @param pid
     * @param cname
     * @param score
     * @return
     */
    @Override
    public boolean updateScore(Integer pid, String cname, double score) {
        if (gradeMapper.updateScore(pid, cname, score)!=0){
            return true;
        }
        return false;
    }

    /**
     * 根据前端传来的选手ID，比赛ID来删除比赛信息
     * @return
     */
    @Override
    public boolean deleteScore(Integer pid, String cname) {
        if (gradeMapper.deleteScore(pid, cname)!=0){
            return true;
        }
        return false;
    }
}
